#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}


struct Node {
    int x, y, z;
};

int m, n, l, t;
int res = 0;

int arr[1300][130][70];
bool st[1300][130][70];

int X[6] = {1, 0, 0, -1, 0, 0};
int Y[6] = {0, 1, 0, 0, -1, 0};
int Z[6] = {0, 0, 1, 0, 0, -1};

bool check(int x, int y, int z) {
    if (x < 0 || x >= m || y < 0 || y >= n || z < 0 || z >= l) return false;
    if (arr[x][y][z] == 0 || st[x][y][z]) return false;
    return true;
}

void bfs(int x, int y, int z) {
    int cnt = 0;
    queue<Node> q;
    q.push({x, y, z});
    st[x][y][z] = true;
    while (q.size()) {
        Node top = q.front(); q.pop();
        cnt ++ ;
        for (int i = 0; i < 6; i ++ ) {
            int dx = top.x + X[i];
            int dy = top.y + Y[i];
            int dz = top.z + Z[i];
            if (check(dx, dy, dz)) {
                st[dx][dy][dz] = true;
                q.push({dx, dy, dz});
            }
        }
    }
    if (cnt >= t) 
        res += cnt;
}

// 三维立体的BFS
inline void solution() {
    cin >> m >> n >> l >> t;
    for (int i = 0; i < l; i ++ ) 
        for (int j = 0; j < m; j ++ ) 
            for (int k = 0; k < n; k ++ )
                cin >> arr[j][k][i];


    for (int i = 0; i < l; i ++ )
        for (int j = 0; j < m; j ++ )
            for (int k = 0; k < n; k ++ )
                if (arr[j][k][i] == 1 && !st[j][k][i])
                    bfs(j, k, i);
    
    cout << res << endl;
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}